package ro.imv.server.gcmDatastore.utils;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.FetchOptions;
import com.google.appengine.api.datastore.PreparedQuery;
import com.google.appengine.api.datastore.Query;
import com.google.appengine.api.datastore.Query.FilterOperator;

public class EntityUtils {

	public static Boolean entityExists(DatastoreService datastore, String senderId, String regId){
		Boolean toReturn = false;
		Query query = new Query("Client");
		query = query.setFilter(FilterOperator.EQUAL.of("registrationId", regId));
		
		PreparedQuery preparedQuery = datastore.prepare(query);
		int count = preparedQuery.countEntities(FetchOptions.Builder.withLimit(1000));
		toReturn = 0 < count;
		return toReturn;
	}
}
